#pragma once
//general headers for general usage
#include "Dllexport.h"
#include "RendererBase.h"
#include "Exception.h"
#include "tinyxml2.h"
#include "ElementNode.h"
#include "Input.h"
#include <string>
#include <map>
#include <functional>
#include "Font.h"

#include "GUIDrawer.h"
#include "Handler.h"


using namespace tinyxml2;
namespace NBGUI
{
	class RendererBase;

	 class GUIAPI GuiCore
	 {
	 public:
		 typedef std::map<std::string,std::function< void(std::vector<info>& i) > > CallBackMap;
		 GuiCore(RendererBase* renderer);
		 ~GuiCore();
		 void initInput();
		 Layout* loadLayout(const char* fileName);//now only support one layout file , todo: multiple layout file 
		 void initDrawing();//default root node
		 void transformCoordnates(ElementNode* element);
		 ElementNode* buildElement(XMLElement* xmlele);
		 void update(int frameRate = 60);//draw

		 void processMessage(MSG msg);

		 ElementNode* buildElementHandlers(ElementNode* element);

		 void addCallBackFunc(std::string& callBackFuncName,const std::function< void(std::vector<info>& i) >& f);
  
	 private:
		 GUIELEMENT castNodeType(const char* tpStr);
		 std::map<std::string, GUIELEMENT> eleTypeMap;
		 GUIDrawer* drawer;

		 std::vector<Input*> inputDevice;
		 CallBackMap callBackFuncMap; 

		 //FunctionCaller caller;


	 };
}